package com.loren.demo33.listener;

import com.loren.demo33.event.BizEvent;
import com.loren.demo33.event.BizEventListener;
import com.loren.demo33.event.ListenerTopic;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

@Slf4j
@Component
@ListenerTopic("111")
public class CouponsHandlerListener implements BizEventListener {

    @Override
    public boolean enable(BizEvent event) {
        return true;
    }

    @Override
    public void onEvent(BizEvent event) {
        Object source = event.getSource();
        @SuppressWarnings("unchecked")
        Map<String, Object> mapInfo = (Map<String, Object>) source;
        log.info("coupons, username = {}, age = {}", mapInfo.get("username"), mapInfo.get("age"));
    }
}